package com.qianyu.api.controller.front;

import com.qianyu.core.entity.base.BaseIdDto;
import com.qianyu.core.entity.base.Result;
import com.qianyu.core.entity.bean.Link;
import com.qianyu.core.entity.bean.LinkAct;
import com.qianyu.core.entity.dto.LinkDto;
import com.qianyu.core.service.LinkActService;
import com.qianyu.core.service.LinkService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "前台管理-任务中心", description = "wangzhicheng")
@RestController
@RequestMapping("/front/link")
@RequiredArgsConstructor
public class LinkController {

    private final LinkService linkService;

    private final LinkActService linkActService;

    /**
     * 新增项目
     */
    @PostMapping("/addLinkActTask")
    @ApiOperation(value = "新增项目")
    Result<String> addLinkActTask(@RequestBody @Validated LinkDto.LinkTaskDto dto) {
        linkService.addLinkActTask(dto);
        return Result.success();
    }

    /**
     * 查询活动链接列表
     */
    @GetMapping("/listLink")
    @ApiOperation(value = "查询活动链接列表")
    Result<List<Link>> listLink() {
        return Result.success(linkService.listLink());
    }

    /**
     * 根据活动链接id查询活动信息
     */
    @PostMapping("/listActByLinkId")
    @ApiOperation(value = "根据活动链接id查询活动信息")
    Result<List<LinkAct>> listActByLinkId(@RequestBody @Validated BaseIdDto dto) {
        return Result.success(linkService.listActByLinkId(dto));
    }

    /**
     * 参加活动
     */
    @PostMapping("/joinActivity")
    @ApiOperation(value = "参加活动")
    Result<String> joinActivity(@RequestBody @Validated LinkDto.LinkActDto dto) {
        linkActService.joinActivity(dto);
        return Result.success();
    }
}
